<!doctype html>
<html>

<head>
	<meta charset="utf-8">
	<title>无标题文档</title>
	<link href="/static/css/default.css" rel="stylesheet" type="text/css">
	<link href="/static/css/style/green.css" rel="stylesheet" type="text/css" id='link'>
</head>

<body style="overflow:hidden; padding:10px;">
	<form>
			<div class="classify">{$parenttitle}</div>
		<table class="formtable" style="width:100%;">

			<tbody>

				<tr>
					<td class="tlabel">选择班级</td>
					<td id="myclass">
							{volist name="myclass" id="vo"}
								
								<input type="checkbox" name="class" data-classid="{$vo.id}" value="{$vo.id}" /> {$vo.classname} &nbsp;
								{/volist}
					</td>
				</tr>
				
				<tr>
					<td class="tlabel">选择用户</td>
					<td>
						<div style="float:left"><input type="checkbox"  id="allchoose"   /> 全选</div>
						<div id="userlist"></div>
					</td>
				</tr>
				<tr>
					<td class="tlabel">选择套餐</td>
					<td>
						<select type="text" id="model" class="select">
								{volist name="config" id="vo"}
								<option value="{$vo.id}" data-money="{$vo.money}">{$vo.title} {$vo.money} 元</option>
							{/volist}
						
						</select>
					</td>
				</tr>

				<tr>
						<td class="tlabel">开通时间(月)</td>
						<td>
								<select type="text" id="month" class="select" v-model="checked">
									
										<option value="1">1</option>
										<option value="2">2</option>
										<option value="3">3</option>
										<option value="4">4</option>
										<option value="5">5</option>
										<option value="6">6</option>
										<option value="7">7</option>
										<option value="8">8</option>
										<option value="9">9</option>
										<option value="10">10</option>
										<option value="11">11</option>
										<option value="12">12</option>
									
									</select>
						</td>
					</tr>






			</tbody>

		</table>

		<div class="formbtn">
			<input type="button" value="提交" class="btnsave">
			<input type="button" value="取消" class="btncancel">
		</div>
		<input type="hidden" id="id" value="{$info.id}" />
	</form>


</body>
<script type="text/javascript" src="/static/js/jquery.js"></script>
<script type="text/javascript" src="/static/js/common.js"></script>
<script type="text/javascript" src="/static/js/vue2.js"></script>
<script src="/static/js/layer/layer.js"></script>
<script>
 

	$(function () {
		$("input[name='class']").click(function(){
			var classid =$(this).data("classid");
			var arr = [];
			$.each($('input[name="class"]:checkbox:checked'),function(){
				arr.push($(this).val());
            });
			var classlist =  arr.join(',');
			if(classlist!=""){
				$.post("/Index/Student/GetStudentList",{"classlist":classlist},function(data){
					var html="";
					for(var i=0;i<data.length;i++){
						html+="<input type='checkbox' name='student' value='"+data[i].id+"' >"+data[i].truename;
					}

					$("#userlist").html(html);


				});

			}
			
		});

		$("#allchoose").change(function() { 
            if($(this).is(':checked')){
				$("input[name=student]").prop("checked",true);
            }else{
				$("input[name=student]").prop("checked",false);
            }
        });


		$(".btnsave").click(function () {
			var student = [];
			$.each($('input[name="student"]:checkbox:checked'),function(){
				student.push($(this).val());
            });

			var month= $("#month").val();
			var model= $("#model").val();

			var money =  $("#model option:selected").attr("data-money");

			if(student.length==0){
				layer.msg("请选择用户");
				return;
			}
	


			var studentlist =  student.join(',');
			$.post("/Index/User/vip", { "studentlist": studentlist, "month": month,"model":model,"money":money }, function (data) {
				if (data.status == 200) {
					layer.msg(data.message);
					setTimeout(function(){
						window.location.href="/Index/user/order";
					},1000);
					
				} else {
					layer.msg(data.message);
				}
			});
		});
		$(".btncancel").click(function () {
			var index = parent.layer.getFrameIndex(window.name);
			parent.layer.close(index);
		});
	});


</script>

</html>